<template>
  <div class="employee-add">
    <!-- 添加园员工 -->
    <div class="form-section employee-add-main">
      <div class="employee-add-setting" @click="toSetting">添加人员设置</div>
      <Form
        :model="createForm"
        ref="createForm"
        labi-width="100px"
        class="demo-ruleForm"
        :rules="rules"
     
      >
        <div class="form-part">
          <div class="part-item">
            <!-- <Form ref="personInfo"  :rules="personRule"> -->
            <div class="part-title">个人信息</div>
            <ul class="row-list clearfix">
              <template  v-for="(item,index) in personinfoList" >
                 <li class="row-item"  v-if="item.english_cloumn_name == 'name'" >
                  <FormItem label="姓名" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                    <i-input v-model="createForm.name" class="form-input300"></i-input>
                  </FormItem>
                </li>
                
              <li class="row-item"  v-if="item.english_cloumn_name == 'gender'" >
                <FormItem label="性別" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <RadioGroup v-model="createForm.gender">
                    <Radio label="男"></Radio>
                    <Radio label="女"></Radio>
                  </RadioGroup>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'mobile'" >
                <FormItem label="手机号码" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.mobile" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'email'" >
                <FormItem label="个人邮箱" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.email" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'id_type'" >
                <FormItem label="证件类型" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select v-model="createForm.id_type" placeholder="请选择" class="form-input300">
                    <Option
                      v-for="(item,index) in credentials"
                      :key="index"
                      :label="item.value"
                      :value="item.value"
                    ></Option>
                  </i-select>
                </FormItem>
                <!-- <div class="replenish">
                  管理证件类型，
                  <a href>点击这里</a>
                </div> -->
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'id_no'" >
                <FormItem label="证件号码" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.id_no" class="form-input300"></i-input>
                </FormItem>
              </li>
              <!-- <li  class="row-item" v-if="item.english_cloumn_name == 'name'" >
               <FormItem label="身份证有效期" prop="id_date" :label-width="150">
                  <i-input v-model="createForm.id_date" class="form-input300"></i-input>
                </FormItem>
              </li>-->
              <li class="row-item" v-if="item.english_cloumn_name == 'birthday'" >
                <FormItem label="生日" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <DatePicker
                    v-model="createForm.birthday"
                    type="date"
                    class="form-input300"
                    placeholder="选择日期"
                  ></DatePicker>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'is_marry'" >
                <FormItem label="是否已婚" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.is_marry" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'is_fertile'" >
                <FormItem label="是否已育" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.is_fertile" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'country'" >
                <FormItem label="国家地区" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.country" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'nation'" >
                <FormItem label="民族" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select v-model="createForm.nation" placeholder="请选择" class="form-input300">
                    <Option
                      v-for="(item,index) in nation"
                       :key ="index"
                      :label="item.value"
                      :value="item.value"
                    ></Option>
                  </i-select>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'politic_countenance'" >
                <FormItem label="政治面貌" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.politic_countenance" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'wechat'" >
                <FormItem label="微信号" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.wechat" class="form-input300"></i-input>
                </FormItem>
              </li>

              <li class="row-item" v-if="item.english_cloumn_name == 'native_place'" >
                <FormItem label="籍贯" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.native_place" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'native_city'" >
                <FormItem label="户籍城市" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select
                    v-model="createForm.native_city"
                    placeholder="请选择"
                    class="form-input300"
                  >
                    <Option
                      v-for="(item,index) in native_city"
                       :key ="index"
                      :label="item.value"
                      :value="item.value"
                    ></Option>
                  </i-select>
                </FormItem>
              </li>

              <li class="row-item" v-if="item.english_cloumn_name == 'native_address'" >
                <FormItem label="户籍地址" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.native_address" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'work_date'" >
                <FormItem label="参加工作时间" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.work_date" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'highest_education'" >
                <FormItem label="最高学历" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.highest_education" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'school'" >
                <FormItem label="毕业院校" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.school" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'major'" >
                <FormItem label="毕业专业" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.major" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'graduation_time'" >
                <FormItem label="毕业时间" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.graduation_time" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'learning_modality'" >
                <FormItem label="学习形式" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <Select v-model="createForm.learning_modality"  
                  placeholder="请选择" 
                  class="form-input300">
                    <Option
                      v-for="(item,index) in learning_modality"
                      :label="item.value"
                      :key="index"
                      :value="item.value"
                     
                    ></Option>
                  </Select>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'qq'" >
                <FormItem label="QQ号" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.qq" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'telphone'" >
                <FormItem label="工作电话":prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.telphone" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'extension_number'" >
                <FormItem label="分机号" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.extension_number" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'residential_address'" >
                <FormItem label="现居住地" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.residential_address" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'emergency_person'" >
                <FormItem label="主要紧急联系人姓名":prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.emergency_person" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'emergency_mobile'" >
                <FormItem label="主要紧急联系人电话" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.emergency_mobile" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'bankcard_no'" >
                <FormItem label="工资卡卡号" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.bankcard_no" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'bankcard_city'" >
                <FormItem label="工资卡开户城市" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.bankcard_city" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'bankcard_city'" >
                <FormItem label="银行名称" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.bankcard_city" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'social_account'" >
                <FormItem label="个人社保账号" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.social_account" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'accumulation_fund'" >
                <FormItem label="个人公积金账号" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.accumulation_fund" class="form-input300"></i-input>
                </FormItem>
              </li>
              </template>
               
            </ul>
         
          </div>

          <!-- 入职信息 -->
          <div class="part-item">
            <div class="part-title">入职信息</div>
            <ul class="row-list clearfix">
                <template  v-for="(item,index) in entryinfoList" >
              <li class="row-item" v-if="item.english_cloumn_name == 'entry_time'" :index="index">
                <FormItem label="入职时间" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <DatePicker
                    v-model="createForm.entry_time"
                    :options="joinDate"
                    type="date"
                    class="form-input300"
                    placeholder="选择日期"
                  ></DatePicker>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'probation_period'" >
                <FormItem label="试用期" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select
                    v-model="createForm.probation_period"
                    placeholder="请选择"
                    class="form-input217"
                  >
                    <i-option value="试用">试用</i-option>
                    <i-option value="正式">正式</i-option>
                  </i-select>
                  <i-select
                    v-model="createForm.probation_period_type"
                    placeholder="个月"
                    class="form-input75"
                  >
                    <i-option value="个月">个月</i-option>
                    <i-option value="天">天</i-option>
                  </i-select>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'company'" >
                <FormItem label="合同公司" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select v-model="createForm.company" placeholder="请选择" class="form-input300">
                      <Option
                      v-for="(item,index) in work_nature"
                      :label="item.value"
                      :value="item.value"
                       :key ="index"
                    ></Option>
                  </i-select>
                  <Icon
                    type="ios-add-circle-outline"
                    size="30"
                    class="form-option-add-btn"
                    @click="showmodal"
                  />
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'department'" >
                <FormItem label="部门" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select 
                  v-model="createForm.organization_id" 
                  placeholder="请选择" 
                  @on-change="orgChange"
                  :label-in-value="true"
                  class="form-input300">
                     <Option
                      v-for="(item,index) in orgList"
                      :value="item.value"
                      :label="item.label"
                      :key ="index"
                    ></Option>
                  </i-select>
                  <Icon
                    type="ios-add-circle-outline"
                    size="30"
                    class="form-option-add-btn"
                    @click="showmodal('department')"
                  />
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'post'" >
                <FormItem label="职务" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select v-model="createForm.post" placeholder="请选择" class="form-input300">
                   <Option
                      v-for="(item,index) in selecte.post"
                      :value="item.value"
                      :label="item.value"
                       :key ="index"
                    ></Option>
                  </i-select>
                  <Icon
                    type="ios-add-circle-outline"
                    size="30"
                    class="form-option-add-btn"
                    @click="showmodal('post')"
                  />
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'position'" >
                <FormItem label="岗位" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select v-model="createForm.position" placeholder="请选择" class="form-input300">
                    <Option
                      v-for="(item,index) in selecte.position"
                      :value="item.value"
                        :label="item.value"
                      :key ="index"
                    ></Option>
                  </i-select>
                  <Icon
                    type="ios-add-circle-outline"
                    size="30"
                    class="form-option-add-btn"
                    @click="showmodal('position')"
                  />
                </FormItem>
              </li>
              <!-- <li class="row-item" v-if="item.english_cloumn_name == 'post_level'" >
                <FormItem label="职级" prop="post_level" :label-width="150">
                  <i-select v-model="createForm.post_level" placeholder class="form-input300">
                      <Option
                      v-for="item in selecte.post"
                      :value="item.value"
                    ></Option>
                  </i-select>
                    <i-input v-model="createForm.post_level" class="form-input300"></i-input>
            
                </FormItem>
              </li> -->
              <li class="row-item" v-if="item.english_cloumn_name == 'work_nature'" >
                <FormItem label="工作性质" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select v-model="createForm.work_nature" placeholder class="form-input300">
                     <Option
                      v-for="(item,index) in work_nature"
                      :value="item.value"
                        :label="item.value"
                      :key="index"
                    ></Option>
                  </i-select>
                </FormItem>
                <!-- <div class="replenish">
                  管理工作性质，
                  <a href>点击这里</a>
                </div> -->
              </li>
                <li class="row-item" v-if="item.english_cloumn_name == 'employee_status'" >
                <FormItem label="员工状态" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select v-model="createForm.employee_status" placeholder class="form-input300">
                    <i-option value="试用">试用</i-option>
                    <i-option value="正式">正式</i-option>
                  </i-select>
                
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'work_no'" >
                <FormItem label="工号" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.work_no" class="form-input300"></i-input>
                </FormItem>
              </li>
            
              <li class="row-item" v-if="item.english_cloumn_name == 'work_city'" >
                <FormItem label="工作城市" prop="work_city" :label-width="150">
                   <Cascader :data="work_city" v-model="createForm.work_city" @on-change = "workCityChange" class="form-input300"></Cascader>
                </FormItem>
              </li>

              <li class="row-item" v-if="item.english_cloumn_name == 'work_place'" >
                <FormItem label="工作地点" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-select v-model="createForm.work_place" placeholder="请选择" class="form-input300">
                     <Option
                      v-for="(item,index) in selecte.work_place"
                      :value="item.value"
                        :label="item.value"
                      :key="index"
                    ></Option>
                  </i-select>
                  <Icon
                    type="ios-add-circle-outline"
                    size="30"
                    class="form-option-add-btn"
                    @click="showmodal('work_place')"
                  />
                </FormItem>
              </li>

              <li class="row-item" v-if="item.english_cloumn_name == 'attendance_no'" >
                <FormItem label="考勤编号" :prop="item.is_require == 1 ?item.english_cloumn_name:''" :label-width="150">
                  <i-input v-model="createForm.attendance_no" class="form-input300"></i-input>
                </FormItem>
              </li>

              <!-- <li class="row-item" v-if="item.english_cloumn_name == 'name'" >
                <FormItem label="工作邮箱" prop="work_email" :label-width="150">
                  <i-input v-model="createForm.work_email" class="form-input300"></i-input>
                </FormItem>
              </li>

              <li class="row-item" v-if="item.english_cloumn_name == 'name'" >
                <FormItem label="汇报上级" prop="work_email" :label-width="150">
                  <i-input v-model="createForm.work_email" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'name'" >
                <FormItem label="招聘渠道" prop="work_email" :label-width="150">
                  <i-input v-model="createForm.work_email" class="form-input300"></i-input>
                </FormItem>
              </li>
              <li class="row-item" v-if="item.english_cloumn_name == 'name'" >
                <FormItem label="档案编号" prop="work_email" :label-width="150">
                  <i-input v-model="createForm.work_email" class="form-input300"></i-input>
                </FormItem>
              </li> -->
                </template>
            </ul>
          </div>

          <div class="form-row footer-row">
            <div class="row-center">
              <div class="form-footer-wrap">
                <Button type="default" class="btn-font-green-border" size="large" @click="save(1)">保存并继续添加</Button>
                <Button type="primary" size="large" @click="save">保存</Button>
              </div>
            </div>
          </div>
          <!-- 入职登记 -->
        </div>
      </Form>


     <!-- 合同公司 -->
       <Modal v-model="modal.company" title="添加合同公司" @on-ok="ok('company')" @on-cancel="cancel('company')">
        <Form>
          <FormItem label="合同公司" prop="name" :label-width="92">
            <i-input v-model="add.compay" class="form-input300" placeholder="请输入..."></i-input>
          </FormItem>
        </Form>
      </Modal>


  
      <!-- 添加部门-->
       <Modal v-model="modal.department" title="添加部门" @on-ok="ok('department')" @on-cancel="cancel('department')">
        <Form>
          <FormItem label="部门名称" prop="name" :label-width="92">
            <i-input v-model="add.department" class="form-input300" placeholder="请输入..."></i-input>
          </FormItem>
         
        </Form>
      </Modal>


      <!-- modal 添加职务 -->
      <Modal v-model="modal.post" title="添加职务" @on-ok="ok('post')" @on-cancel="cancel('post')">
        <Form>
          <FormItem label="职务名称" prop="name" :label-width="92">
            <i-input v-model="add.post" class="form-input300" placeholder="请输入..."></i-input>
          </FormItem>
          <FormItem label="职务编码" prop="name" :label-width="92">
            <i-input v-model="add.code" class="form-input300" placeholder="请输入..."></i-input>
          </FormItem>
          <FormItem label="职务说明" prop="name" :label-width="92">
            <i-input
              type="textarea"
              v-model="add.desc"
              class="form-input300"
              placeholder="请输入..."
            ></i-input>
          </FormItem>
        </Form>
      </Modal>

      <!-- 岗位 -->
       <Modal v-model="modal.position" title="添加岗位" @on-ok="ok('position')" @on-cancel="cancel('position')">
        <Form>
          <FormItem label="岗位" prop="name" :label-width="92">
            <i-input v-model="add.position" class="form-input300" placeholder="请输入..."></i-input>
          </FormItem>
        </Form>
      </Modal>

   

      <!-- 工作地点 -->
      <Modal v-model="modal.work_place" title="添加工作地点" @on-ok="ok('work_place')" @on-cancel="cancel('work_place')">
        <Form>
          <FormItem label="工作地点" prop="name" :label-width="92">
            <i-input v-model="add.work_place" class="form-input300" placeholder="请输入..."></i-input>
          </FormItem>
        </Form>
      </Modal>

    

    </div>
  </div>
</template>
<script>
import { personnel as api } from "@/apis";
import http from "@/utils/http";
import commonRules from "@/utils/rules";
import selectList from "@/utils/selecteList.js";
export default {
  name: "employee-add",
  data() {
    return {
      ...selectList,
      genderRadio: "1",
      modal:{
        compay:false,
        post:false,
        position:false,
        department:false,
        work_place:false
      },
      add_compay:{
        name:""
      },
      add:{
        desc:"",
        code:"",
        post:"",
        department:"",
        work_place:""
      },
      selecte:{
        post:[],
        compay:[],
        work_place:[],
        position:[],
        department:[],
      },
      work_place:{},
      post:{
        name:"",
        code:"",
        desc:""

      },
      form2:{//提交前需要处理的字段
        learning_modality:"",
        form2:[],
      },
      credentials: [
        {
          value: "身份证",
          label: "身份证"
        },
        {
          value: "护照",
          label: "护照"
        },
        {
          value: "军官证",
          label: "军官证"
        },
        {
          value: "其他",
          label: "其他"
        }
      ],
      formType: [
        {
          radioGroup: [{ gender: ["男", "女"] }, {}]
        },
        {
          input: ["name", "mobile"]
        },
        {
          date: ""
        },
        {
          select: ""
        },
        {
          add: ""
        },
        {
          modal: ""
        }
      ],
      modal1: false,
      switch1: "",
      value1: "2020-10-20",
      credentialValue: "",
      orgList:[],

      createForm: {
        name: "",
        gender: "",
        mobile: "",
        email: "",
        id_type: "",
        id_no: "",
        entry_time: "",
        probation_period: "",
        post: "",
        position: "",
        post_level: "",
        work_nature: "",
        employee_status: "",
        work_no: "",
        work_place: "",
        work_city: [],
        attendance_no: "",
        work_email: "",
        organization_id:"",
        organization_name:"",
      },
      native_city: [],
      nation: [],
      createValidate: {},
      personinfoList: [], //个人信息
      entryinfoList: [], // 入职信息
      rules:commonRules,
    };
  },
  methods: {
    showmodal(type) {
      this.modal[type] = true;
    },
    cancel() {},
    ok(type) {
        this.selecte[type].push({
          value:this.add[type]
        })
        console.log('input:',this.add[type]);
        this.createForm[type] = this.add[type];
        console.log(  this.createForm[type]);
        
    },
    getPersonInfo() {
      http
        .get(api.personinfo, {})
        .then(res => {
          let tmp = [];
          let rule = [];
          res.data.forEach(e => {
            if (e.is_show == 1) {
              tmp.push(e);
            }
          });
          this.personinfoList = tmp;
          console.log("personinfoList", tmp);
          this.getEntryInfo();
          this.hideLoading();
          // this.getTableTitle(); //更新表格表头
          // this.closeTableTitle(); // 关闭面板
        })
        .catch(error => {
          console.log("getPersonInfo,", error);
          this.hideLoading();
        });
    },

    // 获取入职信息列表
    getEntryInfo() {
      http
        .get(api.entryinfo, {})
        .then(res => {
          let tmp = [];
          let rule = [];
          res.data.forEach(e => {
            if (e.is_show == 1) {
              tmp.push(e);
            }

          });
          this.entryinfoList = tmp;
         
          let concat = this.personinfoList.concat(tmp);
          let _submitForm = {};
          concat.forEach(e => {
              _submitForm[e.english_cloumn_name] = "";
          });
          _submitForm.work_city = [];
          this.createForm = _submitForm;
          console.log(this.createForm);
          console.log("entryinfoList", tmp);
        })
        .catch(error => {
          console.log("getEntryInfo,", error);
        });
    },

    // 保存
    save(e) {
      console.log(this.createForm);
      this.$refs["createForm"].validate(valid => {
        if (valid) {
          let formData = Object.assign([],this.createForm ) ;;
          // let work_city = formData.work_city;
          // if (work_city) {
          //   formData.work_city = work_city.join(",");
          // }
          http.post(api.employeecreate,{data:formData}).then( (res) => {
            this.$Message.success("保存成功");
          
            if(e == 1){
              this.$refs["createForm"].resetFields(); // 保存并继续添加，重置表单
            }else{
              this.$router.push("/personnel/employee/roster/list");
            }
            
          })
        } else {
          this.$Message.error('请填写必要信息');
        }
      });
    },


    getFormItemList() {},
    getRuleList() {},


    selecteChange(e){
      console.log(e);
      this.createForm.learning_modality = e;
    },

    
    toSetting(){
      this.$router.push("/company-settings/add-rule/detail?type=1");
    },
    showLoading(){
      this.$Spin.show({
          render: (h) => {
              return h('div', [
                  h('Icon', {
                      'class': 'demo-spin-icon-load',
                      props: {
                          type: 'ios-loading',
                          size: 18
                      }
                  }),
                  h('div', '')
              ])
          }
      });
    },
    hideLoading(){
      this.$Spin.hide();
    },
    workCityChange(a,b){
      // this.createForm.work_city = a.join(',');
    },
    reset(){

    },
    getOrg() {
      this.$getOrgList().then(res => {
        let list =res.data.list ||[];
        let temp =[];
         list.forEach(e => {
              temp.push({
                value: e.organization_id,
                label: e.organization_name
              });
            });
      this.orgList = temp;
      });
    },
    orgChange(e){
      console.log(e);
      this.createForm.organization_name=e.label;
    }
  },
  mounted() {
    this.showLoading();
    this.getFormItemList();
    this.getRuleList();
    this.getEntryInfo();
    this.getPersonInfo();
    this.getOrg();
  
  }
};
</script>
<style lang="scss" scoped src="../add.scss">
</style>